import React, { Suspense } from 'react';
import { BrowserRouter as Router, useRoutes } from 'react-router-dom';

import routes from './router';


// 使用 useRoutes 钩子渲染路由
const AppRoutes = () => {
  const element = useRoutes(routes);
  return element;
};

// 主应用组件
const App = () => {
  return (
    <Router>
      <Suspense fallback={<div>Loading...</div>}>
        <AppRoutes />
      </Suspense>
    </Router>
  );
};

export default App;
